//输入: strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
//输出: [["bat"],["nat","tan"],["ate","eat","tea"]]
var groupAnagrams = function(strs) {
    const map = new Map();
    strs.forEach(str => {
        const transStr = Array.from(str).sort().join('')
        const targetArr = map.get(transStr)
        if(targetArr){
            targetArr.push(str)
        }else{
            map.set(transStr,[str])
        }
    });
    return [...map.values()]
};
const result = groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"])
console.log(result)